import http from "../http/index";
const authBaseUrl:string = 'http://u.xlmediawatch.com'
const apiBaseUrl:string = 'http://api.xlmediawatch.com'
const INEWSAPI:string = '/INEWSAPI'

// 登录
export function userLogin(params: any) {
    return http.request({
        baseURL:apiBaseUrl + INEWSAPI,
        headers: {'Content-Type': 'application/x-www-form-urlencoded'},
        url: `/api/vcode/verify/${params.username}/${params.password}`,
        method: "get",
    })
}

// token
export function sureToken(data: any) {
    return http.request({
        baseURL:authBaseUrl,
        headers: {'Content-Type': 'application/x-www-form-urlencoded'},
        url: `/auth/realms/xlplatform/protocol/openid-connect/token`,
        method: "post",
        data
    })
}

// 获取验证码
export function getAuthCode(params: any) {
    return http.request({
        baseURL:apiBaseUrl + INEWSAPI,
        url: `/api/phone/vcode/${params}/l`,
        method: "get",
    })
}

// 获取注册验证码
export function getEnrollAuthCode(params: any) {
    return http.request({
        baseURL:apiBaseUrl + INEWSAPI,
        url: `/api/phone/vcode/${params}/r`,
        method: "get",
    })
}

// 获取个人信息
export function userInfo() {
    return http.request({
        url: `/user`,
        method: "get",
    })
}

// 获取userinfo
export function getUserInfo() {
    return http.request({
        headers: {'Content-Type': 'application/x-www-form-urlencoded'},
        baseURL:authBaseUrl,
        url: `/auth/realms/xlplatform/protocol/openid-connect/userinfo`,
        method: "get",
    })
}

// 查询是否有优惠券
export function searchUserAct(data:any) {
    return http.request({
        // headers: {'Content-Type': 'application/x-www-form-urlencoded'},
        // baseURL:'http://192.168.0.213:8090',
        baseURL:apiBaseUrl + INEWSAPI,
        url: `/inews/coupon/search`,
        method: "post",
        data
    })
}
